<?php
// [ 应用入口文件 ]
namespace pidan;

define('DEBUG',1);//方便改    传递给程序内app->isDebug


if(!DEBUG){
	define('APCU_PREFIX','z_');//缓冲前缀,避免其它站的共用与覆盖,   不设置composer,lang,config 无apcu缓冲
}

require __DIR__ . '/../vendor/autoload.php';

$app=new App();
$m= $_REQUEST['m'] ?? '';//与mode不同
if($m=='t'){

	$app->setMode('thin')->setInitializers(['app\mode\thin\initializer\RegisterService'])->initialize();//只引入app容器，及公共的配置  公共函数
	//根据pathinfo得出app controller action
	$path_info =  trim($_SERVER['REQUEST_URI'],'/');
	//去除?a=1
	if(strpos($path_info,'?')!==false)$path_info =  substr($path_info,0,strpos($path_info,'?'));

	if($path_info==''){
		$path_info='/index/index/index';
	}
	list($app1,$controller, $action) =explode('/',$path_info);

	$contr=$app['\\app\\'.$app1.'\\controller\\'.ucfirst($controller)];// \app\index\controller\Index
	echo $contr->$action();
	
}
else{
	// 执行HTTP应用并响应                         命名名home因为解析index复杂，index留给解析域名
	$http = $app->http;
	($response =$http->run())->send();
	$http->end($response);

	//echo '<br>'.(microtime(true)-$_SERVER['REQUEST_TIME_FLOAT']);

	//file_put_contents('timeout.txt', microtime(true)-$_SERVER['REQUEST_TIME_FLOAT']);
}


